From: Ian Jackson Date: Tue, 22 Jun 2010 15:07:00 +0000 (+0100) Subject: Check "mac" address sooner in device_create function, before doing device_add. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~11889^2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=c1acfe560ba36ee1df3cb92253e507b4369f9585;p=xen.git Check "mac" address sooner in device_create function, before doing device_add. In XendDomainInfo.py device_create function, when device type is "vif", it has a paragraph to check the validity of "mac" address. Before checking validity, device_add has been done. But after checking validity, if the mac address is invlid, it raises VmError and exits directly without doing clean work like removing the device item from config info. This will cause that the incorrect mac address is saved into VM Config file and VM fails to restart. If check "mac" validity before doing device_add, there will be no problem. Signed-off-by Chunyan Liu --- diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 18e8395855..91aa7b696a 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -833,11 +833,6 @@ class XendDomainInfo: @type dev_config: SXP object (parsed config) """ log.debug("XendDomainInfo.device_create: %s" % scrub_password(dev_config)) - dev_type = sxp.name(dev_config) - dev_uuid = self.info.device_add(dev_type, cfg_sxp = dev_config) - dev_config_dict = self.info['devices'][dev_uuid][1] - log.debug("XendDomainInfo.device_create: %s" % scrub_password(dev_config_dict)) - if dev_type == 'vif': for x in dev_config: if x != 'vif' and x[0] == 'mac': @@ -845,6 +840,11 @@ class XendDomainInfo: log.error("Virtual network interface creation error - invalid MAC Address entered: %s", x[1]) raise VmError("Cannot create a new virtual network interface - MAC address is not valid!"); + dev_type = sxp.name(dev_config) + dev_uuid = self.info.device_add(dev_type, cfg_sxp = dev_config) + dev_config_dict = self.info['devices'][dev_uuid][1] + log.debug("XendDomainInfo.device_create: %s" % scrub_password(dev_config_dict)) + if self.domid is not None: try: dev_config_dict['devid'] = devid = \